package com.bjpowernode.web.converter;

import org.springframework.core.convert.converter.Converter;

public class String2IntegerConverter implements Converter<String, Integer> {
    @Override
    public Integer convert(String s) {
        System.out.println("自定义Integer转换器");
        if (s == null || s.isEmpty()) {
            return null;
        }

        // "20.1" ===> "20"
        s = s.substring(0, s.indexOf("."));

        return Integer.parseInt(s);
    }
}
